API 参考

所有端点基础路径: http://dash_lean.ai8.pw/api/v1/


目录


健康检查

GET /health

{ "status": "ok" }

回测 API

方法 路径 说明
GET /api/v1/strategies 策略列表
POST /api/v1/backtest 运行回测
GET /api/v1/backtest/{id}/status 回测状态
GET /api/v1/backtest/{id}/result 回测结果
GET /api/v1/results 所有结果列表
GET /api/v1/results/{name} 指定结果详情
GET /api/v1/chart/{name} 图表数据
GET /api/v1/report 综合报告
GET /api/v1/symbols 可用标的列表

模拟交易 API

方法 路径 说明
POST /api/v1/live/start 启动模拟交易
POST /api/v1/live/stop 停止模拟交易
GET /api/v1/live/status 交易状态
GET /api/v1/live/positions 当前持仓
GET /api/v1/live/orders 订单列表
GET /api/v1/live/pnl 盈亏曲线
GET /api/v1/live/signals 信号日志
GET /api/v1/live/risk 风控状态
POST /api/v1/live/kill 紧急停止
GET /api/v1/live/config 配置信息

数据管理 API (阶段A)

GET /api/v1/data/ohlcv

查询 OHLCV 行情数据。

参数:

参数 类型 必填 说明
symbol string 标的代码 (如 SPY)
start string 起始日期 (YYYY-MM-DD)
end string 结束日期 (YYYY-MM-DD)
timeframe string 时间周期 (1d/1h/5m/1m), 默认 1d
source string 数据源, 默认全部
limit int 返回条数, 默认 1000

响应:

{
  "symbol": "SPY",
  "timeframe": "1d",
  "count": 252,
  "data": [
    {
      "time": "2025-01-02T00:00:00Z",
      "open": 470.50,
      "high": 472.30,
      "low": 469.10,
      "close": 471.80,
      "volume": 65432100,
      "vwap": 471.15
    }
  ]
}

GET /api/v1/data/flow

查询 L2 资金流数据。

参数:

参数 类型 必填 说明
symbol string 标的代码
start string 起始日期
end string 结束日期
flow_type string 类型: option/darkpool/block
min_premium float 最低权利金
limit int 返回条数, 默认 500

GET /api/v1/data/sources

获取所有数据源及状态。

响应:

{
  "sources": [
    {
      "id": 1,
      "name": "yfinance",
      "layer": "L1",
      "api_type": "rest",
      "enabled": true,
      "last_sync": "2026-03-01T16:30:00Z",
      "status": "ok",
      "record_count": 63000
    }
  ]
}

POST /api/v1/data/sync/{source}

手动触发数据源同步。

路径参数: - source — 数据源名称 (如 yfinance)

请求体 (可选):

{
  "symbols": ["SPY", "QQQ"],
  "start": "2025-01-01",
  "end": "2025-12-31"
}

响应:

{
  "status": "started",
  "source": "yfinance",
  "task_id": "sync_abc123"
}

GET /api/v1/data/quality

获取数据质量报告。

参数:

参数 类型 必填 说明
symbol string 指定标的, 默认全部
layer string 数据层级 (L1/L2/L3/L4)

响应:

{
  "overall_score": 95.2,
  "checks": {
    "completeness": { "score": 98.5, "missing_days": 3 },
    "anomalies": { "score": 92.0, "detected": 5 },
    "latency": { "score": 100, "avg_delay_sec": 120 },
    "consistency": { "score": 90.3, "cross_source_diff": 0.02 }
  },
  "by_symbol": {
    "SPY": { "score": 99.1, "records": 7000, "date_range": ["1998-01-02", "2026-02-28"] },
    "AAPL": { "score": 97.8, "records": 6800, "date_range": ["1998-01-02", "2026-02-28"] }
  }
}

WebSocket

ws://dash_lean.ai8.pw/ws/live

实时模拟交易事件推送。

事件类型:

事件 说明
signal 新信号产生
order 订单状态变化
fill 成交通知
pnl 盈亏更新
risk 风控告警
kill 紧急停止

最后更新: 2026-03-01